<?php


class ListNode {

    public $val;
    public $next;
    public function __construct($val, $next)
    {
    
        $this->val = $val;
        $this->next = $next;
    }

}
$root = new ListNode(10, null);
$node1 = new ListNode(20, null);
$root->next = $node1;

// 遍历链表
while ($root != null) {
    echo $root->val . PHP_EOL;
    $root = $root->next;
}
